#coding=utf-8

from stockdb.misc import *
import stseries.basic as sb

class TdsAnalyzer(object):
    '''统计若干交易日的信息'''
    def __init__(self, tds):
        self.tds = tds
    
    def get_traderate(self):
        return sum([td.price.trade_rate for td in self.tds])
    tr = property(fget=get_traderate)
    
    def get_highest(self, item='highest'):
        return max( [getattr(td.price, item) for td in self.tds] )
    highest = property(fget=get_highest)
   
    def get_lowest(self, item='lowest'):
        return min( [getattr(td.price, item) for td in self.tds] )
    lowest = property(fget=get_lowest)
    
    def get_atr(self):
        return sb.average([td.atr for td in self.tds])
    atr = property(fget=get_atr)
    
    def get_length(self):
        return len(self.tds)
    l = property(fget=get_length)
    
if __name__ == '__main__':
    import sys, getopt
    try:
        opts, args = getopt.getopt(sys.argv[1:], "c:s:e:", ["code=", 'start=', 'end=']) 
    except getopt.GetoptError: 
        print opts
    
    
